package com.kaifamiao.month05.day06;

public class MakeThread extends Thread{

    private final Cook cook;
    public MakeThread(Cook cook, String name) {
        super(name);
        this.cook = cook;
    }

    @Override
    public void run() {
        while (true) {
            try {
                sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            cook.make();
        }
    }

    public static void main(String[] args){
        MyThread thread = new MyThread();
        thread.start();
        try {
            // main 执行， main 等待 thread 执行完
            thread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
